// 引入三级列表数据请求
import { request, requestMock } from "@/utils/http";
// 暴漏请求api的方法
export const getThreeListData = () => {
  return request.get('/api/product/getBaseCategoryList')
}
export const getSearchList = (params) => {
  return request.post('/api/list', params)
}
//请求banner数据
export const requestBannerList = () => {
  return requestMock.get("/banner")
};
//请求floor数据
export const requestFloorList = () => {
  return requestMock.get("/floor")
};
// 请求detail数据
export const requestDetailList = (skuId) => {
  return request.get(`/api/item/${skuId}`)
};
// 添加到购物车 对数量进行修改
export const requestSetShopCarList = ({ skuId, skuNum }) => {
  return request.post(`/api/cart/addToCart/${skuId}/${skuNum}`)
}
// 获取购物车列表
export const requestGetShopCarList = () => {
  return request.get("/api/cart/cartList")
}
// 切换单个商品选中状态
export const requestChangeComState = ({ skuId, isChecked }) => {
  return request.get(`/api/cart/checkCart/${skuId}/${isChecked}`)
}
//修改所有购物车商品的选中状态           skuIdList:请求体数据
export const requestChangeAllComState = (isChecked, skuIdList) => {
  return request.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList)
}
// 删除单个购物车商品
export const requestDeleteCom = (skuId) => {
  return request.delete(`/api/cart/deleteCart/${skuId}`)
}
// 删除所有选中的购物车
export const requestAllSelectCom = (skuIdList) => {
  return request.delete(`/api/cart/batchDeleteCart`, {
    data: skuIdList
  })
}

// 登录注册
// 获取注册验证码
export const requestGetCode = (phone) => {
  return request.get(`/api/user/passport/sendCode/${phone}`)
}
// 注册用户
export const requestRegisterUser = (registerInfo) => {
  return request.post("/api/user/passport/register", registerInfo)
}
// 登录
export const requestLogin = (userInfo) => {
  return request.post("/api/user/passport/login", userInfo)
}
// 登录以后获取用户信息
export const requestUserInfo = () => {
  return request.get("/api/user/passport/auth/getUserInfo")
}
// 登出
export const requestLoginOut = () => {
  return request.get("/api/user/passport/logout");
}
// 获取订单交易页信息 
export const requestUserTrade = () => {
  return request.get('/api/order/auth/trade')
}
// 获取用户地址信息
export const requestUserAddressList = () => {
  return requestMock.get('/address')
}
// 提交订单
export const requestReferTrade = (tradeNo, userInfo) => {
  return request.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`, userInfo)
}
// 获取订单支付信息
export const requestPayDetail = (orderId) => {
  return request.get(`/api/payment/weixin/createNative/${orderId}`)
}
//查看某个订单编号的支付状态
export const requestPayStatus = (orderId) => {
  return request.get(`/api/payment/weixin/queryPayStatus/${orderId}`);
};

//查看订单列表
export const requestOrderList = ({ page, limit }) => {
  return request.get(`/api/order/auth/${page}/${limit}`);
};